<template>
  <div>
    <div class="myTitle" v-if="!token">
      <div class="background"></div>
      <div class="account">
        <van-button type="primary" to="/login" class="toLogin"
          >去登陆</van-button
        >
        <div class="state"><div>游客</div></div>
        <div class="avatar">
          <img
            src="http://liufusong.top:8080/img/profile/avatar.png"
            alt=""
            width="60px"
          />
        </div>
      </div>
    </div>
    <div class="myTitle" v-else>
      <div class="background"></div>
      <div class="account">
        <van-button type="primary" class="toLogin" @click="quit"
          >退出</van-button
        >
        <div class="state">
          <div>{{ list.nickname }}</div>
        </div>
        <div class="avatar">
          <img
            src="http://liufusong.top:8080/img/avatar.png"
            alt=""
            width="60px"
          />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { delToken } from '@/utils/storage'

export default {
  name: 'LoginFunctionality',
  props: {
    list: {
      type: Object,
      default: () => ({})
    },
    token: {
      type: String,
      default: ''
    }
  },
  methods: {
    quit () {
      delToken()
      this.$router.push('/login')
    }
  }
}
</script>

<style lang="less" scoped>
.myTitle {
  height: 300px;
  position: relative;
}
.background {
  height: 190px;
  background-size: contain;
  background-image: url('http://liufusong.top:8080/img/profile/bg.png');
}
.account {
  height: 165px;
  width: 320px;
  left: 7.5%;
  top: 132px;
  position: absolute;
  background-size: contain;
  background-color: #fff;
  border-radius: 2px;
  box-shadow: 0px 0px 10px #959c9b;
}
.avatar {
  position: absolute;
  left: 40%;
  top: -20%;
  height: 70px;
  width: 70px;
  background-color: #fff;
  border-radius: 70px;
  position: relative;
  img {
    position: absolute;
    left: 7%;
    top: 7%;
  }
}
.state {
  position: absolute;
  top: 25%;
  width: 100%;
  div {
    text-align: center;
  }
}
.toLogin {
  position: absolute;
  left: 41%;
  top: 45%;
  width: 60px;
  height: 30px;
  padding: 1px;
  border-radius: 20px;
  font-size: 12px;
}
</style>
